<template>
    <div style="height: 95%;width: 100%;display:flex;justify-content:center;padding-top: 20px">
        <!--弹框DIV 设置弹框的大小的地方-->
        <div style="background: #fff;width: 700px;height: 600px;box-shadow: #D3DCE6 0px 0px 20px;">
            <div style="height:520px;border: #1C84C6;margin-top: 25px" class="scrollbar">
                <div style="height: 30px;">
                    <!--标题-->
                    <span style="font-size: 18px;margin-left: 25px;">
                        新建{{this.leixing}}计划
                    </span>
                    <!--返回列表-->
                        <span style="margin-left: 500px;" @click="tzdz">
                            <i slot="suffix" style="font-size: 30px;color: #D3DCE6" class="el-icon-close"></i>
                        </span>
                </div>
                <!--height:91%;表单在弹框显示多长-->
                <el-scrollbar style="height:91%;padding-top: 20px;">
                    <div class="shugan"></div>
                    <span style="margin-left: 10px;font-size: 14px;">基本信息</span>
                    <br/>
                    <br/>
                    <!--表单-->
                    <el-form style="margin-top:5px;margin-left: 50px;" :rules="rules" size="mini" :model="jihualist" ref="jihualist">
                        <el-row>
                            <el-col :span="10">
                            <el-form-item style="width:250px;">
                                <label slot="label" style="font-size: 13px">主题：</label><br/>
                                <el-input v-model="jihualist.returnedmoneyTheme"></el-input>
                            </el-form-item>
                        </el-col>
                            <el-col :span="8">
                                <el-form-item style="width:250px" prop="returnedmoneyTime">
                                    <label slot="label" style="font-size: 13px">计划{{this.leixing}}日期：</label><br/>
                                    <el-date-picker
                                            v-if="this.xg==0||this.xg==2"
                                            v-model="jihualist.returnedmoneyTime"
                                            type="datetime"
                                            placeholder="选择日期时间"
                                            align="right"
                                            :picker-options="pickerOptions"
                                            style="width:250px">
                                    </el-date-picker>
                                        <el-date-picker
                                                v-if="this.xg==1"
                                                :disabled="true"
                                            v-model="jihualist.returnedmoneyTime"
                                            type="datetime"
                                            placeholder="选择日期时间"
                                            align="right"
                                            :picker-options="pickerOptions"
                                            style="width:250px">
                                    </el-date-picker>
                                </el-form-item>
                            </el-col>
                            <el-col :span="10">
                                <el-form-item style="width:250px;" prop="clientId">
                                    <label slot="label" style="font-size: 13px">客户：</label><br/>
                                    <!--客户名称-->
                                    <el-popover
                                        style="width: 700px; height: 450px;"
                                        placement="right"
                                        trigger="click"
                                        v-model="kehu">
                                    <span style="font-size: 16px;">关联客户模块</span>
                                    <br/>
                                    <el-input @keyup.enter.native="cx" v-model="kehuinput" style="width: 210px; margin-left: 230px; margin-bottom: 10px;">
                                        <i slot="suffix" class="el-input__icon el-icon-search" @click="cx"></i>
                                    </el-input>
                                    <el-button type="primary" style="margin-left: 130px;">新 建</el-button>
                                    <el-table
                                            highlight-current-row
                                            border
                                            ref="kehulist"
                                            :data="kehulist">
                                        <el-table-column type="selection" width="50" align="center" property="clientId"></el-table-column>
                                        <el-table-column width="150" property="clientName" label="客户名称"></el-table-column>
                                        <el-table-column width="100" property="clientRank" label="级别"></el-table-column>
                                        <el-table-column width="150" property="clientMobile" label="手机号码"></el-table-column>
                                        <el-table-column property="clientSite" label="地址"></el-table-column>
                                    </el-table>
                                    <el-pagination
                                            style="margin-left: 350px;"
                                            layout="prev, pager, next"
                                            :page-size="pageSize"
                                            :current-page.sync="currPage"
                                            @current-change="handleCurrentChange"
                                            :total="totalSize">
                                    </el-pagination>
                                    <div style="text-align: center;width: 100%" class="dialog-footer">
                                        <el-button type="primary" @click="xzkehu">保 存</el-button>
                                        <el-button type="primary" @click="kehu = false">取 消</el-button>
                                    </div>
                                    <el-input v-if="this.xg==0" v-model="jihualist.clientId.clientName" placeholder="+添加" slot="reference" :readonly='true' style="width: 250px;"></el-input>
                                </el-popover>
                                    <el-input v-if="this.xg==1||this.xg==2" :disabled="true" v-model="jihualist.clientId.clientName" placeholder="+添加" :readonly='true' style="width: 250px;"></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8" v-if="this.leixing=='回款'">
                                <el-form-item style="width:250px" prop="orderId">
                                    <label slot="label" style="font-size: 13px" >订单：</label><br/>
                                    <!--订单-->
                                    <el-popover
                                            style="width: 700px; height: 450px;"
                                            placement="right"
                                            trigger="click"
                                            v-model="dindan">
                                        <span style="font-size: 16px;">关联订单模块</span>
                                        <br/>
                                        <el-input @keyup.enter.native="cx2" v-model="dindaninput" style="width: 210px; margin-left: 230px; margin-bottom: 10px;">
                                            <i slot="suffix" class="el-input__icon el-icon-search" @click="cx2"></i>
                                        </el-input>
                                        <el-button type="primary" style="margin-left: 100px;">新 建</el-button>
                                        <el-table
                                                highlight-current-row
                                                border
                                                ref="dindanlist"
                                                :data="dindanlist">
                                            <el-table-column type="selection" width="50" align="center" property="returnedmoneyId"></el-table-column>
                                            <el-table-column width="150" property="orderTheme" label="主题"></el-table-column>
                                            <el-table-column label="下单时间" align="center" width="200">
                                                <template slot-scope="d">
                                                    {{d.row.orderTime | formatDate}}
                                                </template>
                                            </el-table-column>
                                            <el-table-column width="100" property="orderReturned" label="待回款金额"></el-table-column>
                                            <el-table-column width="100" property="orderTotal" label="总金额"></el-table-column>
                                        </el-table>
                                        <el-pagination
                                                style="margin-left: 350px;"
                                                layout="prev, pager, next"
                                                @current-change="handleCurrentChange2"
                                                :page-size="pageSize2"
                                                :current-page.sync="currPage2"
                                                :total="totalSize2">
                                        </el-pagination>
                                        <div style="text-align: center;width: 100%" class="dialog-footer">
                                            <el-button type="primary" @click="xzdd">保 存</el-button>
                                            <el-button type="primary" @click="dindan = false">取 消</el-button>
                                        </div>
                                        <el-input  v-if="this.xg==0" v-model="jihualist.orderId.orderTheme" @focus="dakai" placeholder="+添加" slot="reference" :readonly='true' style="width: 250px;"></el-input>
                                    </el-popover>
                                    <el-input v-if="this.xg==1||this.xg==2" :disabled="true" v-model="jihualist.orderId.orderTheme" placeholder="+添加" :readonly='true' style="width: 250px;"></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8" v-if="this.leixing=='退款'">
                                <el-form-item style="width:250px" prop="returgoodId">
                                    <label slot="label" style="font-size: 13px">退货单：</label><br/>
                                    <!--退货单-->
                                    <el-popover
                                        style="width: 700px; height: 450px;"
                                        placement="right"
                                        trigger="click"
                                        v-model="thdan">
                                    <span style="font-size: 16px;">关联退货单模块</span>
                                    <br/>
                                    <el-input @keyup.enter.native="cx3" v-model="thdaninput" style="width: 210px; margin-left: 230px; margin-bottom: 10px;">
                                        <i slot="suffix" class="el-input__icon el-icon-search" @click="cx3"></i>
                                    </el-input>
                                    <el-button type="primary" style="margin-left: 100px;">新 建</el-button>
                                    <el-table
                                            highlight-current-row
                                            border
                                            ref="thdanlist"
                                            :data="thdanlist">
                                        <el-table-column type="selection" width="50" align="center" property="returgoodId"></el-table-column>
                                        <el-table-column width="150" property="returgoodTheme" label="主题"></el-table-column>
                                        <el-table-column label="退货日期日期" align="center" width="200">
                                            <template slot-scope="d">
                                                {{d.row.returgoodTime | formatDate}}
                                            </template>
                                        </el-table-column>
                                        <el-table-column width="100" property="returgoodYreimburse" label="应退款"></el-table-column>
                                        <el-table-column width="100" property="returgoodReimburse" label="实退款"></el-table-column>
                                    </el-table>
                                    <el-pagination
                                            style="margin-left: 350px;"
                                            layout="prev, pager, next"
                                            @current-change="handleCurrentChange3"
                                            :page-size="pageSize3"
                                            :current-page.sync="currPage3"
                                            :total="totalSize3">
                                    </el-pagination>
                                    <div style="text-align: center;width: 100%" class="dialog-footer">
                                        <el-button type="primary" @click="xzthdan">保 存</el-button>
                                        <el-button type="primary" @click="thdan = false">取 消</el-button>
                                    </div>
                                    <el-input v-if="this.xg==0" v-model="jihualist.returgoodId.returgoodTheme" @focus="dakai2" placeholder="+添加" slot="reference" :readonly='true' style="width: 250px;"></el-input>
                                </el-popover>
                                    <el-input v-if="this.xg==1||this.xg==2" :disabled="true" v-model="jihualist.returgoodId.returgoodTheme" placeholder="+添加" :readonly='true' style="width: 250px;"></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="10">
                                <el-form-item style="width:250px;" prop="returnedmoneyMoney">
                                    <label slot="label" style="font-size: 13px">金额：</label><br/>
                                    <el-input v-model="jihualist.returnedmoneyMoney"></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item style="width:250px;">
                                    <label slot="label" style="font-size: 13px">付款方式：</label><br/>
                                    <el-input v-model="jihualist.returnedmoneyPayment"></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="10">
                                <el-form-item style="width:250px;">
                                    <label slot="label" style="font-size: 13px">外币备注：</label><br/>
                                    <el-input v-model="jihualist.returnedmoneyBuck" v-if="this.xg==0||this.xg==2"></el-input>
                                    <el-input v-model="jihualist.returnedmoneyBuck" v-if="this.xg==1" :disabled="true"></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item style="width:250px;" prop="returnedmoneyRate">
                                    <label slot="label" style="font-size: 13px">与人民币汇率：</label><br/>
                                    <el-input v-model="jihualist.returnedmoneyRate" v-if="this.xg==0||this.xg==2"></el-input>
                                    <el-input v-model="jihualist.returnedmoneyRate" v-if="this.xg==1" :disabled="true"></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="10">
                                <el-form-item style="width:250px;" prop="returnedmoneyIssue">
                                    <label slot="label" style="font-size: 13px">期次：</label><br/>
                                    <el-input-number style="width:250px" v-if="this.xg==0||this.xg==2"  v-model="jihualist.returnedmoneyIssue" controls-position="right" :min="1" :max="10"></el-input-number>
                                    <el-input-number style="width:250px" v-if="this.xg==1" :disabled="true" v-model="jihualist.returnedmoneyIssue" controls-position="right" :min="1" :max="10"></el-input-number>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item style="width:250px;">
                                    <label slot="label" style="font-size: 13px">所有者：</label><br/>
                                    <el-input :disabled="true" v-model="jihualist.returnedmoneyOwner"></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="18">
                                <el-form-item>
                                    <label slot="label" style="font-size: 13px">备注：</label><br/>
                                    <textarea style="width: 580px;" v-model="jihualist.returnedmoneyRemark" placeholder="备注说明"></textarea>
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </el-form>
                    <br/>
                    <br/>
                </el-scrollbar>
                <!--确定按钮 设置了固定定位-->
                <div style="text-align: center;width: 80%;position: absolute;top:635px;left:230px;" class="dialog-footer">
                    <el-button  @click="tzdz()">取 消</el-button>
                    &nbsp;&nbsp;
                    <el-button type="primary" @click="addbusiness('jihualist')" >确 定</el-button>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    import {formatTimeToStr} from '../router//format.js'
    export default {
        name: "ZxinzenHueikuan",
        data () {
            var hueikuan = (rule, value, callback) => {
                if (this.jihualist.clientId.clientName === null || this.jihualist.clientId.clientName === '') {
                    callback(new Error('请先选择客户'));
                } else {
                    if(this.jihualist.returgoodId.returgoodTheme === null || this.jihualist.returgoodId.returgoodTheme===''){
                        if (this.jihualist.orderId.orderTheme === '' || this.jihualist.orderId.orderTheme === null) {
                            callback(new Error('请选择订单'));
                        }else {
                            callback()
                        }
                    }else {
                        callback()
                    }
                }
            };
            var thd = (rule, value, callback) => {
                if (this.jihualist.clientId.clientName === null || this.jihualist.clientId.clientName === '') {
                    callback(new Error('请先选择客户'));
                } else {
                    if(this.jihualist.orderId.orderTheme === null || this.jihualist.orderId.orderTheme===''){
                        if (this.jihualist.returgoodId.returgoodTheme === '' || this.jihualist.returgoodId.returgoodTheme === null) {
                            callback(new Error('请选择退货单'));
                        }else {
                            callback()
                        }
                    }else {
                        callback()
                    }
                }
            };
            var kehua = (rule, value, callback) => {
                if (value.clientName === null || value.clientName === '') {
                    callback(new Error('请选择客户'));
                }else {
                    callback()
                }
            };
            var jine = (rule, value, callback) => {
                if (!value) {
                    callback(new Error('请输入金额'));
                } else {
                    var numReg = /^[0-9]*$/
                    var numRe = new RegExp(numReg)
                    if (!numRe.test(value)) {
                        callback(new Error('金额只能为正数字'));
                    }else {
                        if (value <=0) {
                            callback(new Error('金额只能为正数字'));
                        }else {
                            if(this.jihualist.returgoodId.returgoodId!=-1 || this.jihualist.orderId.orderId!=-1){
                                if(value>this.jiage && this.jihualist.orderId.orderId!=-1){
                                    callback(new Error('金额大于剩余回款金额,剩余回款金额：'+this.jiage));
                                }else if(value>this.jiage && this.jihualist.returgoodId.returgoodId!=-1){
                                    callback(new Error('金额大于剩余退款金额,剩余回款金额：'+this.jiage));
                                }else {
                                    callback()
                                }
                            }else {
                                callback(new Error('请先选择'+this.jihualist.returnedmoneyRefund+"计划"));
                            }
                        }
                    }
                }
            };
            var hueilv = (rule, value, callback) => {
                if (!value) {
                    callback()
                }else{
                    if(!this.jihualist.returnedmoneyBuck){
                        callback(new Error('请先输入外币备注'));
                        this.jihualist.returnedmoneyRate='';
                    } else {
                        callback()
                    }
                }
            };
            return {
                rules: {
                    clientId: [
                        {validator: kehua, required: true, trigger: ['blur','change']},
                    ],
                    orderId: [
                        {validator: hueikuan, required: true, trigger: ['blur','change']},
                    ],
                    returgoodId: [
                        {validator: thd, required: true, trigger: ['blur','change']},
                    ],
                    returnedmoneyTime: [
                        {required: true, message: '请选择计划回款时间', trigger: 'change' },
                    ],
                    returnedmoneyMoney: [
                        {validator: jine, required: true, trigger: ['blur','change']},
                    ],
                    returnedmoneyRate: [
                        {validator: hueilv, trigger: 'blur',},
                    ],
                    returnedmoneyIssue: [
                        {required: true, message: '请选择期次', trigger: 'change' },
                    ]

                },
                //表单回款计划对象
                jihualist:{
                    returnedmoneyId:0,
                    orderId:{
                        orderId:-1,
                        busId:null,
                        clientId:null,
                        conId:null,
                        orderNo:null,
                        orderTheme:null,
                        orderTotal:null,
                        orderReturned:null,
                        orderInvoice:null,
                        orderGross:null,
                        orderTime:null,
                        orderExchange:null,
                        orderReturn:null,
                        orderState:null,
                        orderRemark:null,
                        orderPeople:null,
                        zbartersByOrderId:null,
                        zdeliverylogsByOrderId:null,
                        zorderdetailsByOrderId:null
                    },
                    clientId:{
                        clientId:0,
                        updateTime:'',
                        clientIndustry:'',
                        clientSource:'',
                        clientUrl:'',
                        establishPerson:'',
                        establishTime:'',
                        clientName:'',
                    },
                    returgoodId:{
                        returgoodId:-1,
                        orderId:null,
                        clientId:null,
                        returgoodNo:null,
                        returgoodTime:null,
                        returgoodYreimburse:null,
                        returgoodReimburse:null,
                        returgoodWarehouse:null,
                        returgoodState:null,
                        returgoodReturnstate:null,
                        returgoodPass:null,
                        returgoodPeople:null,
                        returgoodZt:null,
                        returgoodTheme:null,
                    },
                    returnedmoneyTheme:'',
                    returnedmoneyMoney:'',
                    returnedmoneyTime:'',
                    returnedmoneyIssue:'',
                    returnedmoneyRetuen:'否',
                    returnedmoneyOwner:'',
                    returnedmoneyPayment:'',
                    returnedmoneyRefund:'',
                    returnedmoneyBuck:'',
                    returnedmoneyRate:'',
                    returnedmoneyRemark:'',
                    returnedmoneyInvoice:'未开发票',
                    returnedmoneyZt:0,
                },
                //判断是否为修改
                xg:0,
                hktk:1,
                pickerOptions: {//开票日期快捷选择方式
                    disabledDate(time) {
                        return time.getTime() < Date.now();
                    },
                shortcuts: [{
                    text: '今天',
                    onClick(picker) {
                        picker.$emit('pick', new Date());
                    }
                    }, {
                        text: '昨天',
                        onClick(picker) {
                            const date = new Date();
                            date.setTime(date.getTime() - 3600 * 1000 * 24);
                            picker.$emit('pick', date);
                        }
                    }, {
                        text: '一周前',
                        onClick(picker) {
                            const date = new Date();
                            date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
                            picker.$emit('pick', date);
                        }
                    }]
                },
                kehu:false,//客户弹出框
                kehuinput:'',//客户弹框搜索框
                kehulist:[],//客户表格信息
                pageSize:5,//客户分页页大小
                currPage:1,//客户当前页码，默认为1
                totalSize:0,//客户总记录数
                dindan:false,//订单弹出框
                dindaninput:'',//订单弹框搜索框
                dindanlist:[],//订单表格信息
                pageSize2:5,//订单分页页大小
                currPage2:1,//订单当前页码，默认为1
                totalSize2:0,//订单总记录数
                thdan:false,//退货单弹出框
                thdaninput:'',//退货单弹框搜索框
                thdanlist:[],//退货单表格信息
                pageSize3:5,//退货单分页页大小
                currPage3:1,//退货单当前页码，默认为1
                totalSize3:0,//退货单总记录数
                thdandan : false,
                leixing : '',
                yuanjiage:0,
                jiage:0,
                ys:1,
                ydx:10,
                dz:'',
                bq:''
            };
        },
        methods:{
            tzdz(){
                if(this.dz==='ddzy'){
                    this.$router.push({
                        path:'/dindan',
                        query: {ys:this.ys,ydx:this.ydx}
                    });
                }else if(this.dz==='hkzy'){
                    this.$router.push({
                        path:'/huikuan',
                        query: {ys:this.ys,ydx:this.ydx,row:this.bq}
                    });
                }else if(this.dz==='hhzy'){
                    this.$router.push({
                        path:'/huanhuo',
                        query: {ys:this.ys,ydx:this.ydx}
                    });
                }else {
                    this.$router.push({
                        path:'/dindan',
                        query: {ys:this.ys,ydx:this.ydx}
                    });
                }
            },
            /*当前页方法*/
            handleCurrentChange(val) {
                this.initData(val);
            },
            /*当前页方法*/
            handleCurrentChange2(val) {
                this.ddinitData(val);
            },
            /*当前页方法*/
            handleCurrentChange3(val) {
                this.thdinitData(val);
            },
            /*客户查询*/
            cx() {
                this.initData(this.currPage);
            },
            /*订单查询*/
            cx2() {
                this.ddinitData(this.currPage2);
            },
            /*退货单查询*/
            cx3() {
                this.thdinitData(this.currPage3);
            },
            //确定按钮
            addbusiness(formName) {
                if(this.xg!=0){
                    this.xzfapiao();
                }else{
                    this.$refs[formName].validate(valid => {
                        this.print(valid);
                        window.console.log(valid)
                        if (valid) {
                            this.xzfapiao();
                        }else{
                            this.$message({
                                message: '验证不通过！',
                                type: 'warning'
                            });
                            return false;
                        }

                    });
                }
            },
            //点击回款退款按钮显示隐藏回款退款弹出框
            hktkff(){
                window.console.log(this.jihualist.returnedmoneyRefund)
                if(this.jihualist.returnedmoneyRefund == '退款'){
                    this.hktk = 1;
                }else{
                    this.hktk = 2;
                }
            },
            //点击退货单输入框就查询退货单信息
            dakai2(){
                this.thdaninitData(this.currPage3);
            },
            //选择退货单确定按钮
            xzthdan() {
                this.$refs.thdanlist.selection.forEach((pro)=>{
                    this.jihualist.returgoodId=pro;
                    this.jiage =this.jihualist.returgoodId.returgoodReimburse;
                });
                this.thdan=false;
                this.thdaninput='';
            },
            //退货单查询方法
            thdaninitData(){
                this.$axios.post("http://localhost:8088/thdan/list_thd",this.qs.stringify(
                    {search:this.thdaninput,search2:this.jihualist.clientId.clientId, page:this.currPage3, size:this.pageSize3,}))
                    .then(v=>{
                        this.thdanlist = v.data.rows;
                        this.totalSize3 = v.data.total;
                    })
                    .catch()
            },
            //点击订单输入框就查询订单信息
            dakai(){
                this.ddinitData(this.currPage2);
            },
            //选择客户确定按钮
            xzkehu() {
                this.$refs.kehulist.selection.forEach((pro)=>{
                    this.jihualist.clientId=pro;
                });
                this.kehu=false;
                this.kehuinput='';
            },
            //客户查询方法
            initData(dd){
                this.$axios.post("http://localhost:8088/dindan/kehu_list", this.qs.stringify(
                    {search:this.kehuinput, page:dd, size:this.pageSize,}))
                    .then(v=>{
                        this.kehulist = v.data.rows;
                        this.totalSize = v.data.total;
                    })
                    .catch()
            },
            //选择订单确定按钮
            xzdd() {
                this.$refs.dindanlist.selection.forEach((pro)=>{
                    this.jihualist.orderId=pro;
                    this.jiage = this.jihualist.orderId.orderReturned;
                });
                this.dindan=false;
                this.dindaninput='';
            },
            //订单查询方法
            ddinitData(dd){
                this.$axios.post("http://localhost:8088/dindan/list_dd",this.qs.stringify(
                    {search3:'回款',search:this.dindaninput,search2:this.jihualist.clientId.clientId, page:dd, size:this.pageSize2,}))
                    .then(v=>{
                        this.dindanlist = v.data.rows;
                        this.totalSize2 = v.data.total;
                    })
                    .catch()
            },
            //新增修改回款计划
            xzfapiao() {
                var busform=JSON.stringify({jh:this.jihualist,yuanjg:this.yuanjiage})
                window.console.log(busform)
                this.$axios.post("http://localhost:8088//add_jh", this.qs.stringify({busfrom:busform}))
                    .then(() => {
                        if (this.xg == 0 ||this.xg == 2 ) {
                            this.$message({
                                showClose: true,
                                type: 'success',
                                message: '新增成功!',
                            });
                            this.tzdz();
                        } else {
                            this.$message({
                                showClose: true,
                                type: 'success',
                                message: '修改成功!',
                            });
                            this.tzdz();
                        }
                    }).catch(() => {
                        if (this.xg == 0) {
                            this.$message({
                                showClose: true,
                                message: '新增失败',
                                type: 'error'
                            });
                        } else {
                            this.$message({
                                showClose: true,
                                message: '修改失败',
                                type: 'error'
                            });
                        }
                    }
                )
            }
        },
        created: function () {
            this.initData(this.currPage);
            this.jihualist.returnedmoneyOwner= JSON.parse(localStorage.getItem("user")).empName;
            if(this.$route.query.row!=null){
                this.leixing = this.$route.query.row;
                this.jihualist.returnedmoneyRefund=this.$route.query.row;
            }
            if(this.$route.query.key!=null){
                this.jihualist=this.$route.query.key;
                this.yuanjiage=this.jihualist.returnedmoneyMoney;
                if(this.jihualist.returnedmoneyRefund=='回款'){
                    this.jiage =this.jihualist.returnedmoneyMoney+this.jihualist.orderId.orderReturned;
                }else {
                    this.jiage =this.jihualist.returnedmoneyMoney+this.jihualist.returgoodId.returgoodReimburse;
                }
                this.leixing = this.jihualist.returnedmoneyRefund;
                this.xg = 1;
            }
            if(this.$route.query.dd!=null){
                this.jihualist.orderId=this.$route.query.dd;
                this.jihualist.clientId=this.$route.query.dd.clientId;
                this.jihualist.returnedmoneyRefund='回款';
                this.leixing='回款';
                this.xg=2;
                this.jiage = this.$route.query.dd.orderReturned;
            }
            if(this.$route.query.dz!=null){
                this.dz=this.$route.query.dz;
            }
            if(this.$route.query.ys!=null){
                this.ys=this.$route.query.ys;
            }
            if(this.$route.query.ydx!=null){
                this.ydx=this.$route.query.ydx;
            }
            if(this.$route.query.bq!=null){
                this.bq=this.$route.query.bq;
            }
        },
        filters: {
            formatDate: function (time) {
                if (time != null && time != "") {
                    var date = new Date(time);
                    return formatTimeToStr(date, "yyyy-MM-dd");
                } else {
                    return "";
                }
            }
        }
    }
</script>

<style scoped>
    .shugan{
        border-left-color: rgb(70, 205, 207);
        border-left-width: 1.8px;
        height: 10px;
        border-left-style: solid;
        display: inline;
        font-size: 13px;
        margin-left: 25px;
    }

    /deep/ .el-scrollbar__wrap {
        overflow: scroll;
        width: 120%;
        height: 100%;
    }
</style>